package com.cxs.dao.index.impl;

import java.util.Map;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

import com.cxs.dao.DAOFactory;
import com.cxs.dao.index.IndexDAO;
import com.cxs.model.sys.Sys_User;

@Repository
public class IndexDAOImpl extends DAOFactory implements IndexDAO{

	@Override
	public Sys_User login(Map<String, Object> paramMap) {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT id,user_name,");
		sql.append(" user_no,user_account,phone,");
		sql.append(" address,is_use,role_no,company_no");

		sql.append(" FROM c_sys_user t");
		sql.append(" WHERE user_account=:account");
		sql.append(" AND user_password=:password");
		try {
			Sys_User user =  namedParameterJdbcTemplate.queryForObject(sql.toString(), 
					paramMap , new BeanPropertyRowMapper<>(Sys_User.class));
			if(null != user){
				System.out.println(user.getUser_account()+":"+user.getUser_name());
				sql.setLength(0);
				//查询菜单和权限
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
